import Vue from "vue";
import jiess from '@/jiess';
import VueRouter from "vue-router";

let children = [{
	path: "/",
	name: "home",
	component: () => import("@/views/Index.vue"),
	meta: { title: "首页" }
}, {
	path: "/demoForm",
	component: () => import("@/views/demo/demoForm/index.vue"),
	meta: { title: "表单组件" }
}, {
	path: "/demoInteractive",
	component: () => import("@/views/demo/demoInteractive/index.vue"),
	meta: { title: "表单交互" }
}, {
	path: "/demoList",
	component: () => import("@/views/demo/demoList/index.vue"),
	meta: { title: "列表页面" }
}, {
	path: "/demoTan",
	component: () => import("@/views/demo/demoTan/index.vue"),
	meta: { title: "弹框示例" }
}];
const files = require.context('./module', false, /\.js$/);
files.keys().forEach(key => children.push(files(key).default));

Vue.use(VueRouter)

export default new VueRouter({
	mode: "history",
	base: process.env.BASE_URL,
	routes: [{
			path: "/",
			component: () => jiess.components.Home,
			children
		},
		{
			path: "/error_500",
			name: "error_500",
			component: () => jiess.components[500]
		},
		{
			path: "/error_401",
			name: "error_401",
			component: () => jiess.components[401]
		},
		{
			path: "*",
			name: "error_404",
			component: () => jiess.components[404]
		}
	]
});
